home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / text / docs / how2cod4.txt < prev    next >
Text File  |  1993-01-06  |  50KB  |  1,575 lines

  1.            How to write demos that work (Version 4.3) - 3/1/93
  2.            ===================================================
  3.  
  4.               (or How to bash the metal and get away with it)
  5.  
  6.         (or the Amiga Demo Coders Reference Manual)
  7.  
  8.                   by Comrade J, Share and Enjoy (retired)
  9.  
  10. Thanks to everyone on the internet for sending their suggestions,
  11. bug reports and comments to me on this article. I'll try and keep
  12. this up to date and posted here frequently. Coming soon, source
  13. code for a small intro using all these techniques that you can
  14. use as the base for whatever you want to do....
  15.  
  16.  
  17. Now, is anyone out there going to write a good Amiga 1200 demo,
  18. or am I going to have to do it?
  19.  
  20. --------------------------------------------------------------------
  21.  
  22. Most demos I've seen use similar startup code to that I was using back
  23. in 1988. Hey guys, wake up! The Amiga has changed quite a bit since
  24. then.
  25.  
  26. So. Here are some tips on what to do and what not to do:
  27.  
  28.  
  29. 1. RTFM.
  30. ========
  31.  
  32. Read the F**king manuals. All of them. Borrow them off friends or from
  33. your local public library if you have to.
  34.  
  35. Read the "General Amiga Development Guidelines" in the dark grey (2.04)
  36. Hardware Reference Manual and follow them TO THE LETTER.
  37. If it says "Leave this bit cleared" then don't set it!
  38.  
  39. Don't use self-modifying code. A common bit of code I see is:
  40.  
  41. ... in the setup code
  42.  
  43.     move.l  $6c.w,old
  44.  
  45. ... at the end of the interrupt
  46.  
  47.         movem.l    (sp)+,a0-a6/d0-d7
  48.     dc.w    $4ef9               ; jmp instruction
  49. old    dc.l    0                   ; self modifying!!!!
  50.  
  51. DONT DO THIS!
  52.  
  53. This is much better (although it still hits $6c which is not a
  54. good thing - It's much better to use AddIntServer() to call your
  55. interrupts,
  56.  
  57. ... in the setup code
  58.  
  59.     move.l    VBRBase(a0)
  60.     move.l  $6c(a0),old        ; see under VBR below....
  61.  
  62. ... at the end of the interrupt
  63.  
  64.         movem.l    (sp)+,a0-a6/d0-d7
  65.     move.l    old,-(sp)        ; push old address to stack
  66.         rts
  67.  
  68. ... in your data section
  69.  
  70. old    dc.l    0
  71.  
  72.  
  73. 68020 and above processors with cache enabled often barf at the first
  74. piece of code (the cache still contains the JMP 0 instruction
  75. which isn't then altered), but the second piece works fine on the '040.
  76.  
  77.  
  78.  
  79.  
  80.  
  81. 2. Proper Copper startup.
  82. =========================
  83.  
  84. (Please look at the startup example code at the end of this file).
  85.  
  86. IF you are going to use the copper then this is how you should set it
  87. up. The current workbench view and copper address are stored, the
  88. system frozen, and then the copper enabled. On exit the workbench
  89. view is restored.
  90.  
  91. This guarantees(*) your demo will run on an AGA (Amiga 1200) machine,
  92. even if set into some weird screenmode before running your code.
  93.  
  94. Otherwise under AGA, the hardware registers can be in some strange states
  95. before your code runs, beware!
  96.  
  97. The LoadView(NULL) forces the display to a standard, empty position,
  98. flushing the crap out of the hardware registers: Note. There is
  99. a bug in the V39 OS on Amiga 1200/4000 and the sprite resolution is
  100. *not* reset, you will have to do this manually if you use sprites...
  101.  
  102. Two WaitTOF() calls are needed after the LoadView to wait for both the
  103. long and short frame copperlists of interlaced displays to finish.
  104.  
  105. See the bottom of this file for a full, tested, example startup.asm
  106. code, that you can freely use for your own productions.
  107.  
  108. It has been suggested to me that instead of using the GfxBase gb_ActiView
  109. I should instead use the Intuition ib_ViewLord view. This will work
  110. just as well, but there has been debate as to whether in the future
  111. with retargetable graphics (RTG) this will work in the same way. As the
  112. GfxBase is at a lower level than Intuition, I prefer to access it this
  113. way (but thank's for the suggestion Boerge anyway!). Using gb_ActiView
  114. code should run from non-Workbench environments (for example, being
  115. called from within Amos) too... CJ 1, Chris Green (CBM USA) 0 :-)
  116.  
  117.  
  118. * - Nothing is ever guaranteed where Commodore are involved. They
  119. may move the hardware registers into chipram next week :-)
  120.  
  121. 3. Your code won't run from an icon.
  122. ====================================
  123.  
  124. You stick an icon for your new demo (not everyone uses the CLI!) and
  125. it either crashes or doesn't give back all the RAM it uses. Why?
  126.  
  127. Icon startup needs specific code to reply to the workbench message.
  128. With the excellent Hisoft Devpac assember, all you need to do is add
  129. the line
  130.  
  131.     include "misc/easystart.i"
  132.  
  133. and it magically works!
  134.  
  135. For those without Devpac, here is the relevent code:
  136.  
  137. ---------------------------------------------------------
  138.  
  139. * some startup code to make a Workbench execute look like the CLI
  140. * based loosely on RKM Vol 1 page 4-36
  141.  
  142. * Include this at the front of your program
  143. * after any other includes
  144. * note that this needs exec/exec_lib.i
  145.  
  146.     IFND    EXEC_EXEC_I
  147.     include    "exec/exec.i"
  148.     ENDC
  149.     IFND    LIBRARIES_DOSEXTENS_I
  150.     include    "libraries/dosextens.i
  151.     ENDC
  152.  
  153.  
  154.     movem.l    d0/a0,-(sp)        save initial values
  155.     clr.l    returnMsg
  156.  
  157.     sub.l    a1,a1
  158.     move.l    4.w,a6
  159.     jsr    _LVOFindTask(a6)        find us
  160.     move.l    d0,a4
  161.  
  162.     tst.l    pr_CLI(a4)
  163.     beq.s    fromWorkbench
  164.  
  165. * we were called from the CLI
  166.     movem.l    (sp)+,d0/a0        restore regs
  167.     bra    end_startup        and run the user prog
  168.  
  169. * we were called from the Workbench
  170. fromWorkbench
  171.     lea    pr_MsgPort(a4),a0
  172.     move.l    4.w,a6
  173.     jsr    _LVOWaitPort(A6)        wait for a message
  174.     lea    pr_MsgPort(a4),a0
  175.     jsr    _LVOGetMsg(A6)            then get it
  176.     move.l    d0,returnMsg        save it for later reply
  177.  
  178. * do some other stuff here RSN like the command line etc
  179.     nop
  180.  
  181.     movem.l    (sp)+,d0/a0        restore
  182. end_startup
  183.     bsr.s    _main            call our program
  184.  
  185. * returns to here with exit code in d0
  186.     move.l    d0,-(sp)        save it
  187.  
  188.     tst.l    returnMsg
  189.     beq.s    exitToDOS        if I was a CLI
  190.  
  191.     move.l    4.w,a6
  192.         jsr    _LVOForbid(a6)
  193.  
  194.     move.l    returnMsg(pc),a1
  195.     jsr    _LVOReplyMsg(a6)       ; ***** This line was missing from
  196.                                        ; previous articles!!!! **********
  197.  
  198.     jsr    _LVOPermit(a6)
  199.  
  200. exitToDOS
  201.     move.l    (sp)+,d0        exit code
  202.     rts
  203.  
  204. * startup code variable
  205. returnMsg    dc.l    0
  206.  
  207. * the program starts here
  208.     even
  209. _main
  210.  
  211. ---------------------------------------------------------
  212.  
  213.  
  214.  
  215.  
  216. 4. How do I tell if I'm running on an Amiga 1200/4000?
  217. ======================================================
  218.  
  219. Do *NOT* check library revision numbers, V39 OS can and does
  220. run on standard & ECS chipset machines (This Amiga 3000
  221. is currently running V39).
  222.  
  223. This code will check for AGA
  224.  
  225.         move.w    $dff07c,d0
  226.     cmp.b    #$f8,d0
  227.     bne.s    .notaga
  228.  
  229.     ; Do your funky AGA Stuff in here!
  230.  
  231. .notaga
  232.  
  233.  
  234.  
  235.  
  236.  
  237. 5. Use Relocatable Code
  238. =======================
  239.  
  240. If you write demos that run from a fixed address you should be shot.
  241. NEVER EVER DO THIS. It's stupid and completely unnecessary.
  242.  
  243. If you require bitplanes to be on a 64Kb boundary then try the
  244. following (in pseudo-code because I'm too lazy to write it in asm
  245. for you):
  246.  
  247.         for c=0 to (top of chip ram) step 65536
  248.  
  249.         if AllocAbs(c,NUMBER_OF_BYTES_YOU_WANT) == TRUE then goto ok:
  250.  
  251.     next c:
  252.  
  253.         print "sorry. No free ram. Close down something and retry demo!"
  254.         stop
  255.  
  256. ok:    Run_Outrageous_demo with mem at c
  257.  
  258. Keep your code in multiple sections. Several small sections are
  259. better than one large section, they will more easilly fit in and run
  260. on a system with fragmented memory.
  261.  
  262.  
  263.  
  264.  
  265. 6. Don't Crunch demos!
  266. ======================
  267.  
  268. Don't ever use Tetrapack or Bytekiller based packers. They are crap.
  269. Many more demos fall over due to being packed with crap packers than
  270. anything else. If you are spreading your demo by electronic means
  271. (which most people do now, the days of the SAE Demodisks are long
  272. gone!) then assemble your code, and use LHARC to archive it, you
  273. will get better compression with LHARC than with most runtime
  274. packers.
  275.  
  276. If you *have* to pack your demos, then use Powerpacker 4+, Turbo
  277. Imploder or Titanics Cruncher, which I've had no problems with myself.
  278.  
  279.  
  280.  
  281.  
  282. 7. Don't use the K-Seka assembler!
  283. ==================================
  284.  
  285. It's dead and buried. Get a life, get a real assembler. Hisoft Devpac
  286. is probably the best all-round assembler, although I use ArgAsm
  287. which is astonishingly fast. The same goes for hacked versions of
  288. Seka.
  289.  
  290.  
  291.  
  292. 8. Don't use the hardware unless you have to!
  293. =============================================
  294.  
  295. This one is aimed particularly at utility authors. I've seen some
  296. *awfully* written utilities, for example (although I don't want
  297. to single them out as there are plenty of others) the Kefrens
  298. IFF converter.
  299.  
  300. There is NO REASON why this has to have it's own copperlist. A standard
  301. OS-friendly version opening it's own screen works perfectly (I
  302. still use the original SCA IFF-Converter), and multitasks properly.
  303.  
  304. If you want to write good utilities, learn C.
  305.  
  306.  
  307. 9. Beware bogus input falling through to Workbench
  308. ==================================================
  309.  
  310. If you keep multitasking enabled and run your own copperlist remember
  311. that any input (mouse clicks, key presses, etc) fall through to the
  312. workbench. The correct way to get around this is to add an input
  313. server to the IDCMP food chain (see - you *do* have to read the
  314. other manuals!) at a high priority to grab all input events before
  315. workbench/cli can get to them.
  316.  
  317. Look at the sourcecode for Protracker for an excellent example of
  318. how to do the job properly. Well done Lars!
  319.  
  320.  
  321.  
  322. 10. Have fun!
  323. =============
  324.  
  325. Too many people out there (particularly the American OS-Lamic
  326. Fundamentalists) try to tell us that you should never program at a hardware
  327. level. If you're programming for fun, ignore them! But try and put
  328. a little thought into how your code will work on other machines,
  329. nothing annoys people more than downloading 400Kb of demo and then
  330. finding it blows up on their machines. I'm not naming any names, but
  331. there are quite a few groups who I have no intention of downloading
  332. their demos again because I know it's a waste of download. With
  333. the launch of the Amiga 1200 you cannot just write for 1.3 Amiga
  334. 500's any more. Let's go out there and write some shit hot demos!
  335.  
  336.  
  337. 11. Don't Publish Code you haven't checked!
  338. ===========================================
  339.  
  340. Thanks to Timo Rossi for spotting the stupid bug in my copper
  341. setup routine (using LOFList instead of copinit). Funnily enough
  342. my own setup routine uses the correct copinit code:
  343.  
  344. Please ignore the original file (howtocode.txt) and use this instead.
  345.  
  346.  
  347. 12. Copper End
  348. ==============
  349.  
  350. I've remembered where this double copper end comes from:
  351.  
  352. The ArgAsm assembler has copper macros (CMOVE, CWAIT and CEND)
  353. built in, and the CEND macro deliberately leaves two copper
  354. END instructions, the manual states this is important
  355. for compatibility reasons..
  356.  
  357. When I get back to the office on Monday I'll look this up...
  358.  
  359.  
  360.  
  361. 13. Vector Base Register (68010 and up)
  362. =======================================
  363.  
  364. The 68010 and above processors have a Vector Base Register (VBR)
  365. that allows the exception vector table to be placed anywhere in
  366. RAM, including fast ram. This gives some speed benefits to systems
  367. with this running, but at a cost.
  368.  
  369. Anything that accesses the interrupt locations directly, for example:
  370.  
  371.     move.l    $6c.w,old
  372.     move.l    MyWickedInterruptCode,$6c.w
  373.  
  374. won't work...     Unfortunately this includes 99.9% of demos.
  375.  
  376. Boerg Noest (borgen@stud.cs.uit.no) writes....
  377.  
  378. > Next your text should mention VBR. It's easy - like this:
  379. >     move.l 4.w a6
  380. >    moveq   #0,d0
  381. >    btst.b  #AFB_68010,AttnFlags+1(a6)
  382. >    beq     .done
  383. >    movec   vbr,d0
  384. >.done
  385. >    move.l  d0,VBRBase
  386. >    rts
  387. >
  388. then you just
  389. >    move.l     VBRBase,a0
  390.     move.l    $6c(a0),oldinterrupt
  391. >    move.l     #myinterrupt,$6c(a0)
  392. >
  393.  
  394. Ok. I don't know how many people use the VBR to offset their interrupts,
  395. I certainly don't as it breaks too much software on my 3000, and it
  396. only gives a minimal speed increase. The main benefit of the 68010
  397. over the 68000 is the loop cache mode. Common 3 word loops like:
  398.  
  399.     moveq    #50,d0
  400. .lp    move.b    (a0)+,(a1)+    ; one word
  401.     dbra    d0,.lp        ; two words
  402.  
  403. are recognised as loops and speed up dramatically on 68010.
  404.  
  405.  
  406. 14 Using the blitter.
  407. =====================
  408.  
  409. If you are using the blitter in your code and you are leaving the
  410. system intact (as you should) always use the graphics.library
  411. functions OwnBlitter() and DisownBlitter() to take control
  412. of the blitter. Remember to free it for system use, many system
  413. functions (including floppy disk data decoding) use the blitter.
  414.  
  415. Another big mistake I've seen is with blitter/processor timing.
  416.  
  417. Assuming that a particular routine will be slow enough that a blitter
  418. wait is not needed is silly. Always check for blitter finished, and
  419. wait if you need to.
  420.  
  421. Don't assume the blitter will always run at the same speed too. Think
  422. about how your code would run if the processor or blitter were running
  423. at 100 times the current speed. As long as you keep this in mind,
  424. you'll be in a better frame of mind for writing compatible code.
  425.  
  426. Another big source of blitter problems is using the blitter in interrupts.
  427.  
  428. Most demos do all processing in the interrupt, with only a
  429.  
  430. .wt    btst    #6,$bfe001        ; is left mouse button clicked?
  431.     bne.s    .wt
  432.     
  433. loop outside of the interrupt. However, some demos do stuff outside the
  434. interrupt too. Warning. If you use blitter in both your interrupt
  435. and your main code, (or for that matter if you use the blitter via the
  436. copper and also in your main code), you may have big problems....
  437.  
  438. Take this for example:
  439.  
  440.     lea    $dff000,a5
  441.     bsr    WaitBlitterFinish    ; check bits for blitter ready
  442.     move.l    #-1,BLTAFWM(a5)        ; set FWM and LWM in one go
  443.     move.l    #source,BLTAPT(a5)
  444.     move.l    #dest,BLTDPT(a5)
  445.     move.w    #100111110000,BLTCON0(a5)                
  446.     move.w    #0,BLTCON1(a5)        
  447.     move.w    #64*height+width/2,BLTSIZE(a5)    ; trigger blitter
  448.  
  449. There is *nothing* stopping an interrupt, or copper, triggering a
  450. blitter operation between the WaitBlitterFinish call and
  451. your final BLTSIZE blitter trigger. This can lead to total system blowup.
  452.  
  453. Code that may, by luck, work on standard speed machines may die horribly
  454. on faster processors due to timing differences causing this type of
  455. problem to occurr.
  456.  
  457. The safest way to avoid this is to keep all your blitter calls together,
  458. use the copper exclusively, or write a blitter-interrupt routine to
  459. do your blits for you.
  460.  
  461. Always remember to do two blitter-wait-checks... eg:
  462.  
  463.     btst.b    #DMAB_BLTDONE-8,DMACONR(a1)
  464.     btst.b    #DMAB_BLTDONE-8,DMACONR(a1)
  465.  
  466. The first may not give the correct result on machines with early
  467. (non Fat) Agnus chips (eg Amiga 1000, German A2000). The Hardware
  468. Reference manual explains why, if you're interested.
  469.  
  470.  
  471. 15 NTSC
  472. =======
  473.  
  474. As an European myself, I'm naturally biased agains the inferior video
  475. system, but even though the US & Canada have a relatively minor Amiga
  476. community compared with Europe (Sorry, it's true :-) we should still
  477. help them out, even though they've never done a PAL Video Toaster for
  478. us (sob!).
  479.  
  480. You have two options.
  481.  
  482. Firstly, you could write your code only to use the first 200 display
  483. lines, and leave a black border at the bottom. This annoys PAL owners,
  484. who rightly expect things to have a full display. It took long enough
  485. for European games writers to work out that PAL displays were better.
  486.  
  487. You could write code that automatically checked which system it is
  488. running on and ran the correct code accordingly:
  489.  
  490. (How to check: Note, this is probably not the officialy supported method,
  491. but so many weird things happen with new monitors on AGA machines that
  492. I prefer this method, it's simpler, and works under any Kickstart)
  493.  
  494.     move.l    4.w,a6          ; execbase
  495.     cmp.b    #50,PowerSupplyFrequency(a6)    ; 531(a6)
  496.     beq.s    .pal
  497.  
  498.         jmp    I'm NTSC (or more accurately, I'm running from 60Hz power)
  499. .pal    jmp    I'm PAL  (or I'm running from 50hz power).
  500.  
  501.  
  502. If people have already switched modes to PAL, or if they are running
  503. some weird software like the ICD Flicker Free Video Prefs thingy, then
  504. this completely ignores them, but that serves them right for trying
  505. to be clever :-)
  506.  
  507. Probably better would be to check VBlankFrequency(a6) [530(a6)]
  508. as well, if both are 60Hz then it's definately a NTSC machine. If
  509. one or more are 50Hz, then it's probably a better idea to run in PAL.
  510.  
  511. Under Kickstart 2.04 or greater, the Display Database can be accessed.
  512. Any program can enquire of the database what type of displays
  513. are available, so for example "I want a 50hz 15Khz PAL screen. Can
  514. I display it on this Amiga?" (Unfortunately it doesn't take
  515. an ASCII string like that, but it's not much more dificult). Of
  516. course many users will have the default monitor installed (PAL or
  517. NTSC) and not realise that they can have extra modes by dragging
  518. the monitor icon into their Monitors drawer, and of course
  519. this doesn't work on Kickstart 1.3 machines.
  520.  
  521. Now, if you want to force a machine into the other display system
  522. you need some magic pokes: Here you go (beware other bits in
  523. $dff1dc can do nasty things. One bit can reverese the polarity
  524. on the video sync, not to healthy for some monitors I've heard...)
  525.  
  526. To turn a NTSC system into PAL (50Hz)
  527.  
  528.     move.w    #32,$dff1dc        ; Magically PAL
  529.  
  530. To turn a PAL system into NTSC (60Hz)
  531.  
  532.     move.w    #0,$dff1dc        ; Magically NTSC
  533.  
  534. Remember: Not all displays can handle both display systems!
  535. Commdore 1084/1084S, Philips 8833/8852 and multisync monitors
  536. will, and very few US TV's will handle PAL signals (especially
  537. if being used with a NTSC Amiga modulator). I gather that
  538. most NTSC machines are Amiga 2000's, so perhaps this isn't
  539. a problem.
  540.  
  541. So come on you NTSC users, tell us how you would prefer
  542. the demos written!
  543.  
  544.  
  545.  
  546. 16 Programming AGA hardware
  547. ===========================
  548. I've just got this interesting text file which I thought should be
  549. included with this document. I've now translated it into
  550. better English :-)
  551.  
  552.  
  553. "The following information was gathered by Junkie/PMC Fr and Yragael.
  554.  
  555. Junkie bought a 1200 and started to dissassemble the workbench copperlist.
  556. Thanks to this important work and his impressive speed (which lead me
  557. to dissassemble the copperlist too, I (Yragel) bring you the following
  558. information:
  559.  
  560. More will  follow (unless we get the official AGA hardware reference
  561. manual) [You'll be lucky :-) CJ]
  562.  
  563. We now wait to see your productions on the 1200,  and with your cooperation
  564. we can trip into the hardware of the A1200.  [? Are these guys French
  565. or what? :-)]
  566.  
  567. (next  issue:   Sprite  corrections,  HAM8+,  other  graphic modes, 3 words
  568. copperlists ...)
  569.  
  570. ***************************************************************************
  571.  
  572. USING THE SUPERHIRES MODE
  573.  
  574. To  use  the  SuperHires  mode  (1280  pixels  wide), just use the bit 6 of
  575. register $0100
  576.  
  577. bit 6 | Mode SuperHires
  578. -----------------------
  579.   0   | Normal
  580. -----------------------
  581.   1   | SuperHires
  582. -----------------------
  583.  
  584. ***************************************************************************
  585.  
  586. USING 8 BITPLANES
  587.  
  588. The  number  of bitplanes available used to be no more than 7 and was coded
  589. using  the  bits  14 to 12 of register $0100.  To use 8 bitplanes, just use
  590. bit  4  of  register  $0100.   The  value of bits 14 to 12 will then not be
  591. considered anymore (CJ - It's probably better to set this to %111 for
  592. future compatibility)
  593.  
  594. bit 4 | 8 bitplanes mode
  595. ------------------------
  596.   0   | 0 to 7 bitplanes (from bits 12 - 14)
  597. ------------------------
  598.   1   | 8 bitplanes
  599. ------------------------
  600.  
  601. ***************************************************************************
  602.  
  603. ACCESSING 24 BITS COLOURS
  604.  
  605. The 24 bit colour values are coded using 2 words:
  606.  
  607. - the first receives the 4 high bits of each R, G and B componants
  608. - the second receives the 4 low bits of each R, G and B componants
  609.  
  610. To modify a color using 24 bits coding, you must use 2 coppers-moves on the
  611. same  color  register.   The  first move must always be the move of the
  612. word  of  the 3*4 high bits, the second move is the move of the word of the
  613. 3*4 low bits.
  614.  
  615. You set whether to write the high or the low bits
  616. by setting or clearing bit 9 of register $0106
  617.  
  618. bit 9 | Components access
  619. -----------------------------------------------------------------
  620.   0   | Access to the 4 high bits of components R, G and B
  621. -----------------------------------------------------------------
  622.   1   | Access to the 4 low bits of components R, G and B
  623. -----------------------------------------------------------------
  624.  
  625. ** Editorial note: Looks like he got a little confused about
  626. ** high and low bits here:
  627. **
  628. ** Take $f1f200 (a bright yellow), the high-bits word is $ff0
  629. ** (look familiar?), and the low-bits word is $120.   - CJ
  630.  
  631.  
  632.  
  633. ex: change $0180 to $00123456 in the copperlist
  634.  
  635. $01060000
  636. $01800135
  637. $01060200
  638. $01800246
  639.  
  640.  
  641. When  you  want  to  work using the 12 bits color coding mode, the 3*4 bits
  642. value you move to the color register is considered by the copper as the 3*4
  643. high bits.  You don't have to care about $0106.  It seems bit 9 of register
  644. $0106 is initialized to 0 at each copjmp.
  645.  
  646. (Editorial note: The following code *will* work:
  647.  
  648.      $1060000    ; set high bits
  649.     $1800123    ; high bits register 0
  650.     $1820123    ; high bits register 1
  651.     ...         etc
  652.     $1060200    ; set low bits
  653.     $1800456    ; low bits register 0
  654.     $1820567    ; low bits register 1
  655.     ...         etc
  656.  
  657. ie, you don't have to do the high bits and low bits of each colour
  658. immediately after each other. This saves lots of needless $106 commands!)
  659.  
  660.  
  661.  
  662. ***************************************************************************
  663.  
  664. ACCESSING THE 256 COLOURS PALETTE
  665.  
  666. The amiga doesn't work with 256 separate color registers. The same colour
  667. register is used several times to code several colors.
  668.  
  669. The amiga just works with 8 differents palettes of 32 colors each, using
  670. color registers from $0180 to $01BE.
  671.  
  672. You can choose the palette you want to access via the bits 11 to 14 of
  673. register $0106
  674.  
  675.  
  676. bit 14 | bit 13 | bit 12 | Selected palette
  677. --------------------------------------------------------
  678.    0   |    0   |    0   | Palette 0 (color 0 to 31)
  679. --------------------------------------------------------
  680.    0   |    0   |    1   | Palette 1 (color 32 to 63)
  681. --------------------------------------------------------
  682.    0   |    1   |    0   | Palette 2 (color 64 to 95)
  683. --------------------------------------------------------
  684.    0   |    1   |    1   | Palette 3 (color 96 to 125)
  685. --------------------------------------------------------
  686.    1   |    0   |    0   | Palette 4 (color 128 to 159)
  687. --------------------------------------------------------
  688.    1   |    0   |    1   | Palette 5 (color 160 to 191)
  689. --------------------------------------------------------
  690.    1   |    1   |    0   | Palette 6 (color 192 to 223)
  691. --------------------------------------------------------
  692.    1   |    1   |    1   | Palette 7 (color 224 to 255)
  693. --------------------------------------------------------
  694.  
  695. ex: You want to change color 177 to $00123456
  696.  
  697. Color 177 is color $01A2 of palette 5
  698.  
  699.  
  700. $01065000
  701. $01a20135
  702. $01065200
  703. $01a20245
  704.  
  705. * (Editorial note: This was wrong and has been fixed!!! - CJ)
  706.  
  707. ***************************************************************************
  708.  
  709. SWITCHING THE PALETTE
  710.  
  711. You can switch colors. The definition of switching color A and color B is:
  712.  
  713. - Color registers of colors A and B are NOT modified by the switching
  714. - Color  A  is  displayed  using  the  content  of register of  color B and
  715.   vice-versa
  716.  
  717. The  switching  of  palette  can't be used on just n colors of the palette.
  718. Once  you  choose  a  switching  value,  ALL  the  palette's colors will be
  719. switched.   The  switching  value  is  the  value separing the colors to be
  720. switched and is coded with bits 15 to 8 of register $010C.
  721.  
  722. ex: You want all the colors separated by  one  color in the colorlist to be
  723.     switched
  724.  
  725. $0180 <--
  726. $0182 <--|--
  727. $0184 <--   |
  728. $0186 <-----
  729. $0188 <--------
  730.  .             |
  731.  .
  732.  .
  733.  
  734. Value 2 will be stocked in bits 15 to 8.
  735.  
  736. The  switching  works  with the palette as if it was a circular palette.  I
  737. mean  if  if the copper consider color 255 and must switch by 1 the colors,
  738. color $0180 will be assiocated to color 255.      (??? - CJ)
  739.  
  740. (Editorial note: A bit confusing here. the high byte of the $dff10c
  741. register (BPLCON4) seems to be an XOR value:
  742.  
  743. So, if you set the value to $FF, all colour registers are negated,
  744. eg Colour 255 = colour 0, colour 1 = 254, etc...
  745.  
  746. - CJ)
  747.  
  748.  
  749. ***************************************************************************
  750.  
  751. USING SPRITES IN LOWRES, HIRES AND SUPERHIRES
  752.  
  753. To  change  the  reolution  of the sprite, just use bit 7 and 6 of register
  754. $0106
  755.  
  756. bit 7 | bit 6 | Resolution
  757. --------------------------
  758.   0   |   0   | Lowres             (140ns)
  759. --------------------------
  760.   1   |   0   | Hires        (70ns)
  761. --------------------------
  762.   0   |   1   | Lowres        (140ns)
  763. --------------------------
  764.   1   |   1   | SuperHires    (35ns)
  765. --------------------------
  766.  
  767. (Now.. 70ns sprites may not be available unless the Interlace bit in
  768. BPLCON0 is set. Don't ask me why....        CJ)
  769.  
  770. ***************************************************************************
  771.  
  772. USING 16, 32 AND 64 PIXELS WIDE SPRITES
  773.  
  774. Well,  I  still  have bug there with sprites in 32 or 64 pixels.  Sorry but
  775. the followings informations may have to be corrected.
  776.  
  777. Use bit 3 and 2 of register $01FC
  778.  
  779. bit 3 | bit 2 | Wide
  780. -------------------------
  781.   0   |   0   | 16 pixels
  782. -------------------------
  783.   1   |   0   | 32 pixels
  784. -------------------------
  785.   0   |   1   | 32 pixels
  786. -------------------------
  787.   1   |   1   | 64 pixels
  788. -------------------------
  789.  
  790. The  copper  doesn't read the spritelist in the same way regarding the wide
  791. you choose for your sprite
  792.  
  793. 16 pixels wide reading:
  794.  
  795. word C1, word C2
  796. word A1, word B1
  797.  .
  798.  .
  799.  .
  800. word An, word Bn
  801. $0000 0000
  802.  
  803. C1=first control word
  804. C2=second control word
  805.  
  806. Ai and Bi are combined via OR to form the sprite
  807.  
  808. 32 pixels wide reading:
  809.  
  810. long C1, long C2
  811. long A1, long B1
  812.  .
  813.  .
  814.  .
  815. long An, long Bn
  816. $0000 0000 0000 00000
  817.  
  818. C1=first control long
  819.    the  first control word is the high word of C1.  The low word of C1 must
  820.    contain the second control word.
  821. C2=second control long
  822.    the second control word is the high word of C2. Low word of C2 is $0000
  823.  
  824. Ai and Bi are combined via OR to form the sprite
  825.  
  826. 64 pixels wide reading:
  827.  
  828. double C1, double C2
  829. double A1, double B1
  830.  .
  831.  .
  832.  .
  833. double An, double Bn
  834. $0000 0000 0000 00000 0000 0000 0000 00000
  835.  
  836. C1=first control double
  837.    C1=W3:W2:W1:W0 (Wi=words)
  838.    W3 is first control word
  839.    W2 and W1 are second control word
  840. C2=second control double
  841.    C2=W3:W2:W1:W0 (Wi=words)
  842.    W3 is second control word
  843.  
  844. Ai and Bi are combined via OR to form the sprite
  845.  
  846. ***************************************************************************
  847.  
  848. CHANGING THE SPRITE PALETTE
  849.  
  850. It  is possible to choose the color palette of the sprite.  This is done by
  851. the bits 7 and 4 of register $010C.
  852.  
  853. bit 7 | bit 6 | bit 5 | bit 4 | Starting color of the sprite's palette
  854. -------------------------------------------------------------------------
  855.   0   |   0   |   0   |   0   | $0180/palette 0 (coulor 0)
  856. -------------------------------------------------------------------------
  857.   0   |   0   |   0   |   1   | $01A0/palette 0 (color 15)
  858. -------------------------------------------------------------------------
  859.   0   |   0   |   1   |   0   | $0180/palette 1 (color 31)
  860. -------------------------------------------------------------------------
  861.   0   |   0   |   1   |   1   | $01A0/palette 1 (color 47)
  862. -------------------------------------------------------------------------
  863.   0   |   1   |   0   |   0   | $0180/palette 2 (color 63)
  864. -------------------------------------------------------------------------
  865.   0   |   1   |   0   |   1   | $01A0/palette 2 (color 79)
  866. -------------------------------------------------------------------------
  867.   0   |   1   |   1   |   0   | $0180/palette 3 (color 95)
  868. -------------------------------------------------------------------------
  869.   0   |   1   |   1   |   1   | $01A0/palette 3 (color 111)
  870. -------------------------------------------------------------------------
  871.   1   |   0   |   0   |   0   | $0180/palette 4 (color 127)
  872. -------------------------------------------------------------------------
  873.   1   |   0   |   0   |   1   | $01A0/palette 4 (color 143)
  874. -------------------------------------------------------------------------
  875.   1   |   0   |   1   |   0   | $0180/palette 5 (color 159)
  876. -------------------------------------------------------------------------
  877.   1   |   0   |   1   |   1   | $01A0/palette 5 (color 175)
  878. -------------------------------------------------------------------------
  879.   1   |   1   |   0   |   0   | $0180/palette 6 (color 191)
  880. -------------------------------------------------------------------------
  881.   1   |   1   |   0   |   1   | $01A0/palette 6 (color 207)
  882. -------------------------------------------------------------------------
  883.   1   |   1   |   1   |   0   | $0180/palette 7 (color 223)
  884. -------------------------------------------------------------------------
  885.   1   |   1   |   1   |   1   | $01A0/palette 7 (color 239)
  886. -------------------------------------------------------------------------
  887.  
  888. ***************************************************************************
  889.  
  890.  
  891. That's all. Thanx you VERY MUCH to Junkie/PMC Fr for his work.
  892.  
  893.              Written by Yragael. Translated & Bugfixed by Comrade J
  894.                     Chaos.  Live it.  Learn it.  Be it.
  895.  
  896.                      _\!/_ The Illuminated Ones _\!/_
  897.                       /!\  ««««««««««»»»»»»»»»»  /!\
  898.  
  899. Interesting, eh?
  900.  
  901.  
  902. 17. Keyboard Timings
  903. ====================
  904.  
  905. If you have to read the keyboard by hardware, be very careful
  906. with your timings. Not only do different processor speeds affect
  907. the keyboard timings (for example, in the game F-15 II Strike Eagle
  908. on an Amiga 3000 the key repeat delay is ridiculously slow, you
  909. ttyyppee lliikkee tthhiiss aallll tthhee ttiimmee. You use
  910. up an awful lot of Sidewinders very quickly!), but there are differences
  911. between different makes of keyboard (for example, some Amiga 2000's
  912. come with Cherry keyboards, these have small function keys (same
  913. size as normal alphanumeric keys - these keyboards have different
  914. timings to the normal Mitsumi keyboards.
  915.  
  916. Again, here's something from Boerge:
  917.  
  918. >Third, you should warn about f**king up the keyboard read timing. My keyboard
  919. >absolutely does not work with just reading the $bfxxxx turning it to output,
  920. >and writing the reply, and turning it to input again. I do not have any code
  921. >that is especially good, but for now I use this:
  922. >        move.b  $bfec01,d0      ;get keycode
  923. >        not.b   d0
  924. >        lsr.b   #1,d0           ;test up/down flag
  925. >        bcs.s   .NoStore        ;if up, ignore
  926. >
  927. >        move.b  d0,Key
  928. >.NoStore
  929. >
  930. >;handshake
  931. >        bset    #6,$bfee01      ;output
  932. >        clr.b   $bfec01
  933. >        moveq   #4-1,d0
  934. >.L1     move.b  VHPOSR,d1
  935. >.L2     cmp.b   VHPOSR,d1
  936. >        beq.b   .L2
  937. >        dbra    d0,.L1
  938. >
  939. >        bclr    #6,$bfee01      ;input again
  940.  
  941. Remember though, if you have system interrupts and workbench enabled,
  942. keys can fall-through to workbench. For example, press Amiga-Q in
  943. your demo and you may find Workbench closed on return!
  944.  
  945. 18. How to break out of never-ending loops
  946. ==========================================
  947.  
  948. Another great tip for Boerge here:
  949.  
  950. >This is a simple tip I have. I needed to be able to break out of my
  951. >code if I had neverending loops. I also needed to call my exit code when I did
  952. >this. Therefore I could not just exit from the keyboard interrupt which I have
  953. >taken over(along with the rest of the machine). My solution wa to enter
  954. >supervisor mode before I start my program, and if I set the stack back then
  955. >I can do an RTE in the interrupt and just return from the Supervisor() call.
  956. >This is snap'ed from my code:
  957. >
  958. >    lea     .SupervisorCode,a5
  959. >    move.l  sp,a4           ;
  960. >    move.l  (sp),a3         ;
  961. >    EXEC    Supervisor
  962. >    bra     ReturnWithOS
  963. >
  964. >.SupervisorCode
  965. >    move.l  sp,crashstack   ; remember SSP
  966. >    move.l  USP,a7          ; swap USP and SSP
  967. >    move.l  a3,-(sp)        ; push return address on stack
  968. >
  969. >that last was needed because it was a subroutine that RTSes (boy did I have
  970. >porblems working out my crashes before I fixed that)
  971. >Then I have my exit code:
  972. >
  973. >ReturnWithOS
  974. >    tst.l   crashstack
  975. >    beq     .nocrash
  976. >    move.l  crashstack,sp
  977. >    clr.l   crashstack
  978. >    RTE                     ; return from supervisor mode
  979. >.nocrash
  980. >
  981. >my exit code goes on after this.
  982. >
  983. >This made it possible to escape from an interrupt without having to care
  984. >for what the exception frames look like.
  985.  
  986.  
  987.  
  988.  
  989. 19. Version numbers!
  990. ====================
  991.  
  992. Put version numbers in your code. This allows the CLI version command
  993. to determine easily the version of both your source and executable
  994. files. Some directory utilities allow version number checking too (so
  995. you can't accidentally copy a newer version of your source over
  996. an older one, for example). Of course, if you pack your files the
  997. version numbers get hidden. Leaving version numbers unpacked
  998. was going to be added to PowerPacker, but I don't know if this is
  999. done yet.
  1000.  
  1001. A version number string is in the format
  1002.  
  1003. $VER: howtocode4.txt 4.2 02/01/92.
  1004. ^          ^          ^Version number (date is optional)
  1005. |          |
  1006. |          | File Name
  1007. |
  1008. | Identifier
  1009.  
  1010. The Version command searches for $VER and prints the string it finds
  1011. following it.
  1012.  
  1013. For example, adding the line to the begining of your source file
  1014.  
  1015. ; $VER: MyFunDemo.s 4.0 01/01/93
  1016.  
  1017. and somewhere in your code
  1018.  
  1019.     dc.b    "$VER: MyFunDemo 4.0 01/01/93",0
  1020.  
  1021. means if you do VERSION MyFunDemo.s you will get:
  1022.  
  1023. MyFunDemo.s 4.0 01/01/93
  1024.  
  1025. and if you assemble and do Version MyFunDemo, you'll get
  1026.  
  1027. MyFunDemo 4.0 01/01/93
  1028.  
  1029. Try doing version howtocode4.txt and see what you get :-)
  1030.  
  1031. This can be very useful for those stupid demo compilations
  1032. where everything gets renamed to 1, 2, 3, etc...
  1033.  
  1034. Just do version 1 to get the full filename (and real date)
  1035.  
  1036. Does this work on Kickstart 1.3? I can't remember, I ditched
  1037. my 1.3 Kickstart 2 years ago :-)
  1038.  
  1039.  
  1040. 20. CDTV
  1041. ========
  1042.  
  1043. I've been asked if there is any special advice on how to program
  1044. demos to work on CDTV, and if hardware access to the CDTV (for
  1045. playing CD Audio, etc) is possible.
  1046.  
  1047. The CDTV is essentially a 1Mb chip ram Amiga with a CD-ROM drive.
  1048. The major difference (apart from lack of fast ram or $c00000 ram)
  1049. is that the CDTV roms can take up anything from 100-200Kb of ram.
  1050.  
  1051. Many demos fail on CDTV through lack of memory.
  1052.  
  1053. You can hack your CDTV to switch on/off these roms (put a switch
  1054. on JP15), when switched off the CDTV has a full 1Mb of memory and
  1055. more software works, but you can still play audio CD's in the CD
  1056. drive..
  1057.  
  1058. I have no information on how to program the CDTV at the hardware
  1059. level. Currently the only supported way to access the CDTV
  1060. special functions is by the CDTV.DEVICE, a standard ROM device
  1061. that can be OpenDevice()d and sent IORequests. I don't think
  1062. I'm allowed to give out the documentation for this, sorry :-(
  1063.  
  1064. 21. Copper Wait Commands
  1065. ========================
  1066.  
  1067. The Hardware Reference manual states a copper wait for the start
  1068. of line xx is done with:
  1069.  
  1070. $xx01,$fffe
  1071.  
  1072. However (as many of you have found out), this actually triggers
  1073. just before the end of the previous line (around 4 or 5 low-res
  1074. pixels in from the maximum overscan border).
  1075.  
  1076. For most operations this is not a problem (and indeed gives a little
  1077. extra time to initialise stuff for the next line), but if you are
  1078. changing the background colour ($dff180), then there is a noticalbe
  1079. 'step' at the end of the scanline.
  1080.  
  1081. The correct way to do a copper wait to avoid this problem is
  1082.  
  1083. $xx07,$fffe.
  1084.  
  1085. This just misses the previous scanline, so the background colour is
  1086. changed exactly at the start of the scanline, not before.
  1087.  
  1088.  
  1089.  
  1090. 22. Screen Modulos (thanks Magnus for this one...)
  1091. ==================================================
  1092.  
  1093. Don't assume bitplane modulos (BPL0MOD and BPL1MOD) will be
  1094. set to zero. If you require zero modulos set them, at the start
  1095. of your copperlist is as good a place as any.
  1096.  
  1097. Under V39 OS the workbench is interleaved by default, so the
  1098. modulo can be huge...
  1099.  
  1100.  
  1101.  
  1102. 23. Open Graphics Library! (again, thanks Magnus)
  1103. =================================================
  1104.  
  1105. I've never seen this in use before, but Magnus spotted
  1106. it. It's got to be one of the worst pieces of code I've
  1107. ever seen! Don't ever do this!
  1108.  
  1109.     move.l    4.w,a0          ; get execbase
  1110.     move.l    (a0),a0         ; wandering down the library list...
  1111.     move.l    (a0),a0     ; right. I think this is graphics.library
  1112.  
  1113.     ; now goes ahead and uses a0 as gfxbase...
  1114.  
  1115. Oh yes, graphics.library is always going to be second down the chain from
  1116. Execbase?
  1117.  
  1118. LISTEN and LISTEN good. If you want to access gfxbase (or any other
  1119. library base) OPEN the library. Do not wander down the library
  1120. chain, either by guesswork or by manually checking for "graphics.library"
  1121. in the library base name. OpenLibrary() will do this for you.
  1122.  
  1123.  
  1124.  
  1125. 24. Protracker Replay code bug
  1126. ==============================
  1127.  
  1128. I've just got the Protracker 2.3 update, and the replay code (both
  1129. the VBlank and CIA code) still has the same bug from 1.0!
  1130.  
  1131. At the front of the file is an equate
  1132.  
  1133. >DMAWait = 300 ; Set this as low as possible without losing low notes.
  1134.  
  1135. And then it goes on to use 300 as a hard coded value, never refering
  1136. to DMAWait!
  1137.  
  1138. Now, until I can get some free time to write a reliable scanline-wait
  1139. routine to replace their DBRA loops (does anyone want to write a better
  1140. Protracker player? Free fame & publicity :-), I suggest you change
  1141. the references to 300 in the code (except in the data tables!) to
  1142. DMAWait, and you make the DMAWait value *MUCH* higher.
  1143.  
  1144. I use 1024 on this Amiga 3000 without any apparent problem, but
  1145. perhaps it's safer to use a value around 2000. Has anyone tried
  1146. Protracker on a 68040 machine, if so, what DMAWait value in Prefs
  1147. is needed to make all modules sound ok?
  1148.  
  1149. 25. Optimise mode on produces crap code?
  1150. ========================================
  1151.  
  1152. If you're using Devpac and have found that the OPT o+ flag produces
  1153. crap code, then you need to add the option o3-. I can't remember
  1154. what this option does, my Devpac 3 manual is at the office.
  1155.  
  1156. 26. Argasm produces crap code, whatever happens
  1157. ===============================================
  1158.  
  1159. First, Argasm (unlike Devpac) from the Command Line or if called from
  1160. Arexx using Cygnus Ed (my prefered system) defaults to writing linkable
  1161. code, so you need to add
  1162.  
  1163.         opt    l-        (disable linkable code)
  1164.  
  1165. If you find that your Argasm executables fail then check you haven't
  1166. got any BSR's across sections! Argasm seems to allow this, but of
  1167. course the code doesn't work. Jez San from Argonaut software who
  1168. publish ArgAsm says it's not a bug, but a feature of the linker...
  1169.  
  1170. Yeah right Jez...
  1171.  
  1172. But Argasm is *fast*, and it produces the *fastest* non-working
  1173. code of any assembler :-)
  1174.  
  1175. I still use it though, but Devpac comes in handy for checking
  1176. code every now and then. Argonaut have abandoned ArgAsm so
  1177. the last version (1.09d) is the last. There will be no more...
  1178.  
  1179.  
  1180. 27. Help! I'm starting to code in assembler. Where do I begin?
  1181. ==============================================================
  1182.  
  1183. If you are just starting to learn programming, and you want
  1184. a good place to begin learning assembler, buy Amos!. It's
  1185. very easy to write assembler code, load it into amos and test it.
  1186.  
  1187. For example, take this routine:
  1188.  
  1189. ;simplemaths.s
  1190.  
  1191.         add.l    d0,d1        ; add contents of d0 to d1
  1192.         rts
  1193.  
  1194. Assemble this with Devpac and what do you get? Not a lot.
  1195.  
  1196. Now, load AMOS and type this:
  1197.  
  1198. Pload "ram:simplemaths",1  ' load executable file into bank 1
  1199. Input "Enter a number ";n1
  1200. Input "Enter another number ";n2
  1201. dreg(0) = n1    ' Store n1 in 68000 register d0
  1202. dreg(1) = n2    ' Store n2 in 68000 register d1
  1203. call(1)         ' Run your machinecode routine
  1204. Print n1;" plus ";n2;" equals ";dreg(1)    ' returns result in d1
  1205.  
  1206. You can start playing with 68000 instructions this way, seeing how
  1207. they work, without having to 'jump in the deep end' writing
  1208. routines to set up displays, copperlists, windows or writing to
  1209. the console. Once you have got the hang of 68000, you can drop
  1210. Amos.
  1211.  
  1212. 28 How can I tell what processor I am running on?
  1213. =================================================
  1214.  
  1215. Look inside your case. Find the large rectangular (or Square) chip,
  1216. read the label :-)
  1217.  
  1218. Or...
  1219.  
  1220.     move.l    4.w,a6
  1221.     move.w  AttnFlags,d0    ; get processor flags
  1222.  
  1223. d0.w is then a bit array which contains the following bits
  1224.  
  1225. Bit    Meaning if set
  1226.  
  1227. 0    68010 processor fitted
  1228. 1       68020 processor fitted
  1229. 2    68030 processor fitted
  1230. 3       68040 processor fitted
  1231. 4    68881 MMU fitted
  1232. 5    68882 MMU fitted
  1233.  
  1234. There may well be other flags set now, I only have old documentation
  1235. at home..
  1236.  
  1237. DO NOT assume that the system has a >68000 if the word is non-zero!
  1238. 68881 chips are available on add-on boards without any faster processor.
  1239.  
  1240. And don't assume that a 68000 processor means a 7Mhz 68000. It may well
  1241. be a 14Mhz processor.
  1242.  
  1243. So, you can use this to determine whether specific processor functions
  1244. are available (more on 68020 commands in a later issue), but *NOT*
  1245. to determine values for timing loops. Who knows, Motorola may
  1246. release a 100Mhz 68020 next year  :-)
  1247.  
  1248.  
  1249. 29 All addresses are 32 bit
  1250. ===========================
  1251.  
  1252. "Oh look" says clever programmer. "If I access $dcdff180 I can access
  1253. the colour0 hardware register, but it confuses people hacking my
  1254. code!".
  1255.  
  1256. Oh no you can't. On a machine with a 32-bit address bus (any
  1257. accelerated Amiga) this doesn't work. And all us hackers know this
  1258. trick now anyway :-)
  1259.  
  1260. Always pad out 24-bit addresses (eg $123456) with ZEROs in the high
  1261. byte ($00123456). Do not use the upper byte for data, for storing
  1262. your IQ, for scrolly messages or for anything else.
  1263.  
  1264. Similarly, on non ECS machines the bottom 512k of memory was paged
  1265. four times on the address bus, eg:
  1266.  
  1267.     move.l #$12345678,$0
  1268.  
  1269.     move.l    $80000,d0    ; d0 = $12345678
  1270.     move.l    $100000,d1    ; d1 = $12345678
  1271.     move.l    $180000,d2    ; d2 = $12345678
  1272.  
  1273. This does not work on ECS and upwards!!!! You will get meaningless
  1274. results if you try this, so PLEASE do not do it!
  1275.  
  1276. 30. New Chipsets?
  1277. =================
  1278.  
  1279.  
  1280. TO : ALL CODERS IN THE AMIGA DEMO-/GAMESCENE !!!
  1281.  
  1282.  
  1283. New Low- Highend Chipset
  1284. ------------------------
  1285.  
  1286. Got this message from a BBS...
  1287.  
  1288. >As we heard from serious Commodore developers, there
  1289. >will be a new Low-end and a High-end chipset.
  1290.  
  1291. This is no secret. This was announced by Lew Egelbrecht (sp?)
  1292. head of Commodore Engineering a couple of months back
  1293.  
  1294. >The High-end chipset will feature totally new customchips.
  1295. >They will bring 16 Bit Sound and some other new features.
  1296. >There will be no DSP (Digital Signal Processor) like
  1297. >the MOTOROLA 68851 in this AMIGA. Instead of it, there
  1298. >will take a new Commodore own Signal Processor part in this
  1299. >wonderful machine.
  1300.  
  1301. This is not what I heard. I head the AT&T DSP would probably
  1302. be used (a true floating point DSP, unlike the integer one
  1303. found in the Atari Falcon).
  1304.  
  1305. The 68851 is a Memory Management Unit for the 68020, not a DSP.
  1306.  
  1307. >The new chips are not fully compatible to AA Chips. Most of
  1308. >the new AA Registers like $dff106 and $dff10c will be changed.
  1309. >That's the reason, why Commodore didn't released a new
  1310. >A1200 and A4000 Hardware Reference Manual.
  1311.  
  1312. This is exactly what I have heard from *very* reliable sources.
  1313. It may be that AGA chips are a temporary solution inbetween
  1314. ECS and the new (AAA?) Superchips...
  1315.  
  1316. I wonder if the low-end AAA chipset will be any more AGA
  1317. compatible than the high-end?
  1318.  
  1319. >The old Registers won't be changed.
  1320. >Consequence: If Coders use the old (Normal & ECS) registers,
  1321. >that are documented from Commodore, there are no probs with
  1322. >the High-end chips. But if they use AA Registers, the new
  1323. >AMIGA will propably CRASH.
  1324.  
  1325. You have been warned! But what are the chances we get AAA
  1326. hardware information. :-(
  1327.  
  1328. >Probably publishing date of this AMIGA: Summer '93 (August).
  1329.  
  1330. More likely early 1994. CBM won't release any new machines
  1331. while AGA machines are still selling well....
  1332.  
  1333. >
  1334. >Other facts:- The consumer price of the A4000 will turn under
  1335. >           $1200 in 1993!
  1336.  
  1337. Not for the 68040 version. The A4000/030 (Amiga 4000 with
  1338. 25Mhz 680EC30 chip) may reach $1500 or less.
  1339.  
  1340. >            - Kickstart 4.0 is finished!
  1341.  
  1342. Yeah right :-)
  1343.  
  1344. >The truth of this facts is nearly 100 %.
  1345.  
  1346. Hmmmmm....
  1347.  
  1348. >Text from SMC of ABYSS
  1349. >{written on 30.12.92}
  1350.  
  1351. Commented by CJ on 2nd Jan 1993
  1352.  
  1353.  
  1354.  
  1355. 31. Action Replay Cartridges
  1356. ============================
  1357.  
  1358. These things are great fun, even more so if you get into the
  1359. 'sysop mode' (Allows disassembly of ram areas not previously
  1360. allowed by Action Replay, including non-autoconfig ram and
  1361. the cartridge rom!)
  1362.  
  1363. To get into sysop mode on Action Replay 1 type:
  1364.  
  1365. LORD OLAF
  1366.  
  1367. To get into sysop mode on Action Replay 2 type:
  1368.  
  1369. MAY
  1370. THE
  1371. FORCE
  1372. BE
  1373. WITH
  1374. YOU
  1375.  
  1376. To get into sysop mode on Action Replay 3 type the same as
  1377. Action Replay 2. After this you get a message
  1378. "Try a new one".
  1379. Then type in
  1380.  
  1381. NEW
  1382.  
  1383. and sysop powers are granted!
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389. Startup Code
  1390. ============
  1391.  
  1392. I've seperated this out now, cut out this file and keep it safe
  1393. (you may need a grown up to help you with this :-)
  1394.  
  1395. 8<-------8<-------8<-------8<-------8<-------8<-------8<-------8<-------
  1396.  
  1397. *
  1398. * Startup.asm  - A working tested version of startup from Howtocode3.txt
  1399. *
  1400. * CJ - 31/12/92 (Happy new year) [comradej@althera.demon.co.uk]
  1401. *
  1402. * This code sets up one of two copperlists (one for PAL and one for NTSC)
  1403. * machines. It shows something to celebrate 3(?) years since the Berlin
  1404. * wall came down :-) Press left mouse button to return to normality.
  1405. * Tested on Amiga 3000 (ECS/V39 Kickstart) and Amiga 1200 (AGA/V39)
  1406. * Read Howtocode3.txt for information on this source!
  1407. *
  1408. * $VER: startup.asm V2.0 With added fibre and no artificial preservatives
  1409. *
  1410. *
  1411.  
  1412.  
  1413.     opt    l-,o+                 ; auto link, optimise on
  1414.  
  1415. ;     opt    o3-            ; add this for Devpac Assembler
  1416.  
  1417.     section    mycode,code        ; need not be in chipram
  1418.  
  1419.     incdir    "include:"
  1420.     include    "exec/types.i"
  1421.     include    "exec/funcdef.i"    ; keep code simple and
  1422.     include    "exec/exec_lib.i"    ; easy to read - use
  1423.     include    "graphics/gfxbase.i"    ; the includes!
  1424.     include    "graphics/graphics_lib.i"
  1425.  
  1426.     include "misc/easystart.i"    ; Allows startup from
  1427.                     ; icon
  1428.  
  1429.  
  1430. StartCopper:
  1431.     move.l    4.w,a6        ; get ExecBase
  1432.     lea    gfxname,a1    ; graphics name
  1433.     moveq    #0,d0        ; any version
  1434.     jsr    _LVOOpenLibrary(a6)
  1435.     tst.l    d0
  1436.     beq    End        ; failed to open? Then quit
  1437.     move.l    d0,gfxbase
  1438.     move.l    d0,a6
  1439.     move.l    gb_ActiView(a6),wbview
  1440.                 ; store current view address
  1441.                                 ; gb_ActiView = 32
  1442.  
  1443.     move.w    #0,a1        ; clears full long-word
  1444.     jsr     _LVOLoadView(a6)     ; Flush View to nothing
  1445.     jsr    _LVOWaitTOF(a6)     ; Wait once
  1446.     jsr    _LVOWaitTOF(a6)     ; Wait again.
  1447.  
  1448.     move.w    $dff07c,d0
  1449.     cmp.b    #$f8,d0
  1450.     bne.s    .notaga
  1451.  
  1452.     move.w    #0,$dff1fc    ; reset sprites (fix V39 bug)
  1453.  
  1454. .notaga
  1455.                 ; Now you can hit the copper!
  1456.     move.l    4.w,a6
  1457.     jsr    _LVOForbid(a6)  ; Suspend multitasking!
  1458.  
  1459.  
  1460.     cmp.b    #50,VBlankFrequency(a6) ; Am I *running* PAL?
  1461.     bne.s    .ntsc
  1462.  
  1463.     move.l    #mycopper,$dff080     ; bang it straight in.
  1464.     bra.s    .lp
  1465.  
  1466. .ntsc    move.l    #mycopperntsc,$dff080
  1467.  
  1468.  
  1469. .lp    btst    #6,$bfe001
  1470.     bne.s    .lp
  1471.  
  1472.  
  1473. CloseDown:
  1474.     move.l    4.w,a6
  1475.     jsr    _LVOPermit(a6)     ; Enable multitasking
  1476.  
  1477.     move.l    wbview,a1
  1478.     move.l    gfxbase,a6
  1479.     jsr    _LVOLoadView(a6) ; Fix view
  1480.  
  1481.     move.l    gb_copinit(a6),$dff080     ; Kick it into life
  1482.                                          ; copinit = 36
  1483.     move.l    a6,a1
  1484.     move.l    4.w,a6
  1485.     jsr    _LVOCloseLibrary(a6) ; EVERYONE FORGETS THIS!!!!
  1486.  
  1487. End:    rts                           ; back to workbench/clc
  1488.  
  1489.     section mydata,data_c    ; keep data & code seperate!
  1490.  
  1491. mycopper    dc.w    $100,$0200    ; otherwise no display!
  1492.             dc.w    $180,$00
  1493.             dc.w    $8107,$fffe        ; wait for $8107,$fffe
  1494.         dc.w    $180,$f00          ; background red
  1495.         dc.w    $d607,$fffe    ; wait for $d607,$fffe
  1496.         dc.w    $180,$ff0          ; background yellow
  1497.             dc.w    $ffff,$fffe
  1498.             dc.w    $ffff,$fffe
  1499.  
  1500. mycopperntsc
  1501.         dc.w    $100,$0200    ; otherwise no display!
  1502.             dc.w    $180,$00
  1503.             dc.w    $6e07,$fffe        ; wait for $6e07,$fffe
  1504.             dc.w    $180,$f00          ; background red
  1505.         dc.w    $b007,$fffe    ; wait for $b007,$fffe
  1506.         dc.w    $180,$ff0          ; background yellow
  1507.             dc.w    $ffff,$fffe
  1508.         dc.w    $ffff,$fffe
  1509.  
  1510. wbview      dc.l    0
  1511. gfxbase     dc.l    0
  1512. gfxname     dc.b    "graphics.library",0
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524. Thanks to everyone who has replied. Any more questions, queries,
  1525. or "CJ, you got it wrong again!" type mail to the email
  1526. address below....
  1527.  
  1528. Thanks to:  Vic Ricker, Grue, Timo Rossi, Jesse Michael, John Derek Muir,
  1529. Boerge Noest, Christopher Klaus, Doz/Shining, Andrew Patterson, Walter
  1530. Dao and Magnus Timmerby.
  1531.  
  1532. Wanted! If you can write sections on the following, I'd be very
  1533. greatful. Some of these I may do myself eventually..
  1534.  
  1535.  
  1536. Good optimisations (eg lea 16(a0),a1 instead of move.l a0,a1 add.l #16,a1)
  1537.  
  1538. Simple 68881/882 programming introduction
  1539. Bootblocks
  1540.  
  1541. Any other short programming tips & tricks
  1542.  
  1543.  
  1544.  
  1545. --------------------------------------------------------------------
  1546.  
  1547. This text is Copyright (C) 1993 Share and Enjoy, but may be freely
  1548. distributed in any electronic form. The copyright of contributions
  1549. quoted from other authors remains with the original author. If you would
  1550. like to contribute to this file, email me at the address below...
  1551.  
  1552. The startup code in this article is freeware and may be used by
  1553. anyone for any purpose.
  1554.  
  1555. All opinions expressed in this article are my own, and in no way
  1556. reflect those of Share and Enjoy or any BBS this file may be found
  1557. on.
  1558.  
  1559. I didn't write this for fun, I wrote it for you to use! Hopefully
  1560. this will grow into a big file that demo coders can use.
  1561.  
  1562. If you strongly disagree with anything I write, or you want to send me
  1563. some source or demos to test on Amiga 1200/4000 etc, or you have
  1564. questions about Amiga programming, or suggestions for future articles,
  1565. or just want to chat about the best way to optimise automatic copperlist
  1566. generation code, then contact me via email at:
  1567.  
  1568. comradej@althera.demon.co.uk, or in alt.sys.amiga.demos
  1569.  
  1570. I'm having a few problems with sending email at the moment, so please
  1571. be patient if you haven't received a reply. I will try to reply to
  1572. every message within a day or two..
  1573.  
  1574.  
  1575.